package com.wt.struggle.goodbye.user.adapter

import android.content.Context
import android.support.v7.widget.RecyclerView
import android.view.View
import android.view.ViewGroup
import com.wt.struggle.goodbye.R
import com.wt.struggle.goodbye.base.ProBaseAdapter
import com.wt.struggle.goodbye.base.Share
import com.wt.struggle.goodbye.info.ProUserInfo
import com.xin.lv.yang.utils.utils.ImageUtil
import kotlinx.android.synthetic.main.account_item.view.*

class AccountAdapter(context: Context, list: ArrayList<ProUserInfo>) : ProBaseAdapter<ProUserInfo>(context, list) {
    override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) {
        val vh = holder as VH
        val info = list[position]
        ImageUtil.getInstance().loadCircleImage(context, vh.imageUserHead, info.avatarurl, 0)
        vh.tvUserName.text = info.nickName
        vh.tvUserPhone.text = info.account
        val account = Share.getAccount(context)

        if (account == info.account) {
            vh.imageChoose.visibility = View.VISIBLE
        } else {
            vh.imageChoose.visibility = View.GONE
        }

    }

    override fun onCreateView(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder {
        val view = inflater.inflate(R.layout.account_item, parent, false)
        return VH(view)

    }

    override fun onUpdateHolder(holder: RecyclerView.ViewHolder, position: Int, payloads: MutableList<Any>) {

    }

    class VH(view: View) : RecyclerView.ViewHolder(view) {
        val imageUserHead = view.imageUserHead
        val tvUserName = view.tvUserName
        val tvUserPhone = view.tvUserPhone
        val imageChoose = view.imageChoose

    }
}